//依赖
const gulp = require("gulp");
const concat = require("gulp-concat");
const uglify = require("gulp-uglify");
const cleanCss = require("gulp-clean-css");
var sass = require('gulp-sass');
sass.compiler = require('node-sass');

const findSync = require("./utils/index").findSync;
const scssJSON  = require("./conf/index").scss;
const scripts  = require("./conf/index").scripts;

const {
    mergeMyScripts,
    mergeMyScss
} = require('./utils/index');

let scriptsTaskArray = [];
let scssTaskArray = [];


//路径配置 获取当前路径下所有文件路径
function init(){
    scriptsTaskArray = mergeMyScripts(scripts,'scripts-build-','build')
    scssTaskArray = mergeMyScss(scssJSON,'scss-build-','build')
}



//转存html
gulp.task('html-build',()=>{
    return gulp.src(['./src/*.html'])
    .pipe(gulp.dest('./dist'))
})

init() 
//总合并js
gulp.task('scripts-build',scriptsTaskArray)
//总合并scss
gulp.task('scss-build',scssTaskArray)

//启动服务器

gulp.task("build",["html-build",'scripts-build','scss-build'])
